// proxy:DynamicProxyDemo.java

// Broken in JDK 1.4.1_01

package proxy;

import java.lang.reflect.*;

interface Foo {
	void f(String s);

	void g(int i);

	String h(int i, String s);
}

public class DynamicProxyDemo {
	public static void main(String[] clargs) {

		Foo prox = (Foo) Proxy.newProxyInstance(Foo.class.getClassLoader(),
				/*new Class[] { Foo.class }*/Foo.class.getInterfaces(), 
				new InvocationHandler() {
					public Object invoke(Object proxy, Method method,
							Object[] args) {
						System.out.println("InvocationHandler called:\n\tMethod = " + method);
						if (args != null) {
							System.out.println("\targs = ");
							for (int i = 0; i < args.length; i++)
								System.out.println("\t\t" + args[i]);
						}
						return null;
					}
				});

		prox.f("hello");
		prox.g(47);
		prox.h(47, "hello");

	}

} // /:~